<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2018/10/7
 * Time: 16:28
 */
namespace app\admin\controller;
use app\admin\model\CommodityModel;
use think\Db;
class Commodity extends Base
{
    public function index()
    {
        if(request()->isAjax ()){
            extract(input());
            $map = [];
            if(isset($key)&&$key!="")
            {
                $map['g_name|s_name|s_phone'] = ['like',"%" . $key . "%"];
            }
            $map['g_status'] = ['in','1,2'];
            $Nowpage = input('page') ? input('page'):1;
            $limits = input("limit")?input("limit"):10;// 获取总条数;
            $user = new CommodityModel();
            $count = $user->getCommodityCount($map);
            $lists = $user->getCommodityData($map,$Nowpage, $limits);
            return json(['code'=>0,'msg'=>'','count'=>$count,'data'=>$lists]);
        }
        return $this->fetch('commodity/index');
    }
}